var express = require('express');
var router = express.Router();
var passport = require('passport')
var ordercontroller = require('../controllers/ordercontroller')

// 订单信息
router.get('/order', function (req, res, next) {
    ordercontroller.getOrder(req,res)
  // res.send('respond with a resource');
});
//获取购物车信息
router.get('/getTrade',passport.authenticate('jwt',{session:false}), function (req, res, next) {
    ordercontroller.getTrade(req,res)
  // res.send('respond with a resource');
});
//取消订单
router.delete('/delOrder',function(req,res,next){
  ordercontroller.delOrder(req,res)
})
//添加订单
router.post('/inOrder',function(req,res,next){
  ordercontroller.insertOrder(req,res)
})
// 结算
router.get('/end', function (req, res, next) {
  ordercontroller.endOrder(req,res)
  // res.send('respond with a resource');
});
//修改订单
router.put('/updOrder', function (req, res, next) {
  ordercontroller.updOrder(req,res)
  // res.send('respond with a resource');
});
//已完成订单
router.get('/yesOrder',function(req,res,next){
  ordercontroller.yesOrder(req,res)
})
//未完成订单
router.get('/noOrder',function(req,res,next){
  ordercontroller.noOrder(req,res)
})
//未完成订单转已完成订单
router.put('/YesOrder',function(req,res,next){
  ordercontroller.YesOrder(req,res)
})

//查询订单详情表
router.get('/selorderdet',function(req,res,next){
  ordercontroller.selorderdet(req,res)
})

//插入订单详情
router.post('/insertorderdet',function(req,res,next){
  ordercontroller.insertorderdet(req,res)
})
//下订单
router.post('/addOrder',function(req,res,next){
  ordercontroller.addOrder(req,res)
})
//获取购物车内商品信息
router.get('/getTrade',function(req,res,next){
  ordercontroller.getTrade(req,res)
})
module.exports = router